const path = require('path');
const webpack = require('webpack');


module.exports = function (env, argv) {
    return {
        mode: env.production ? 'production' : 'development',
        entry: './src/index.ts',
        output: {
            path: path.resolve(__dirname, 'dist'),
            filename: '[name].bundle.js',
            clean: true,
            library: {
                name: 'DyForm',
                type: 'window',
            },
        },
        module: {
            rules: [
                {
                    test: /\.tsx?$/,
                    use: 'ts-loader',
                    exclude: /node_modules/,
                },
            ],
        },
        resolve: {
            extensions: ['.tsx', '.ts', '.js'],
        },
        plugins: [
            new webpack.SourceMapDevToolPlugin({})
        ],
        devServer: {
            allowedHosts: 'all',
            port: 5566,
            static: ['dist','public'],
            watchFiles: ['src/**/*.*'],
            devMiddleware: {
                writeToDisk: false
            }
        }
    }
}
